﻿using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _读取txt文件
{
    class Program
    {
        static void Main(string[] args)
        {

            string txtPath = " E://Document//Visual Studio 2017//Projects//_测试//_读取txt文件//txtContent.txt";
            DataTable dt = new DataTable();
            dt.Columns.Add("Content", typeof(string));
            string Lines = string.Empty;
            using (StreamReader sr = new StreamReader(txtPath, Encoding.Default))
            {
                while ((Lines = sr.ReadLine()) != null)
                {
                    if (!string.IsNullOrEmpty(Lines))
                    {
                        DataRow dr = dt.NewRow();
                        dr["Content"] = Lines;
                        dt.Rows.Add(dr);
                    }
                }
            }

            Console.ReadKey();
        }
    }
}
